--Pugtastic Core: Initial declerations
--Create addon object with embeded libraries.  Set up locale table "L".
local PugVer = 0.2
local PugtasticCore = LibStub("AceAddon-3.0"):NewAddon("PugtasticCore", "AceConsole-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("PugtasticCore", false)

-- Declare defaults to be used in the database.

local settings
local allplayers
local defaults = {
    global = {
        version = 1,
    },
    profile = {
        setting = true,
    },
}

-- Other local values.




--Template Functions
function PugtasticCore:OnInitialize()
    -- Code that you want to run when the addon is first loaded goes here.

    -- Initialize and load database

    self.db = LibStub("AceDB-3.0"):New("PugtasticDB", defaults)
    --Check for version conflicts.
    settings = self.db.profile
    self:SetupOptions()
end

function PugtasticCore:OnEnable()
    PugtasticCore:Print(L["PUGTASTIC_ENABLED"])
end

function PugtasticCore:OnDisable()
    -- Called when the addon is disabled
    PugtasticCore:Print(L["PUGTASTIC_DISABLED"])
end



--Slash Options
local optionsSlash = {
    name = "PugtasticCore",
    handler = PugtasticCore,
    type = 'group',
    args = {
        intro = {
            order = 1,
            type = "description",
            name = "Pugtastic Slash Commands",
            cmdHidden = true,
        },
        test = {
            type = 'execute',
            name = 'Addon Test',
            desc = L["Simple test for debugging"] .. '(/pug test)',
            func = function () PugtasticCore:SlashTest() end,
        },
    },
}

function PugtasticCore:SetupOptions()
	-- setup options table
	LibStub("AceConfig-3.0"):RegisterOptionsTable("PugtasticCoreSlashCommand", optionsSlash, "pug")
end


--Process Functions
function PugtasticCore:SlashTest()
  -- Process the slash command ('input' contains whatever follows the slash command)
  PugtasticCore:Print(L["Testing Pugtastic..."])
  PugtasticCore:Print(L["DB_LOADED"] .. self.db.global.version)
end

PugtasticCore:Print(L["PUGTASTIC_LOADED"] .. PugVer)